package com.wzy.controller;

import com.wzy.annotation.SystemLog;
import com.wzy.domain.ResponseResult;
import com.wzy.domain.entity.Index;
import com.wzy.domain.vo.IndexVO;
import com.wzy.service.IndexService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 文章索引控制层
 *
 * @author wzy
 * @version 2022/5/21 14:33
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/index")
public class IndexController
{
    private final IndexService indexService;

    /**
     * 提交文章目录索引
     */
    @PostMapping("/postArticleIndex")
    @SystemLog(basenessName = "提交文章目录索引")
    public ResponseResult<Void> postArticleIndex(@RequestBody List<Index> directoryIndex)
    {
        return indexService.postArticleIndex(directoryIndex);
    }

    /**
     * 获取文章目录索引
     */
    // todo:优化索引
    @GetMapping("/getArticleIndex")
    @SystemLog(basenessName = "获取文章目录索引")
    public ResponseResult<List<IndexVO>> getArticleIndex()
    {
        return indexService.getArticleIndex();
    }

}
